* figure 6a

use Diversification.dta

* reduced sample with the Theil decomposition
keep if reduced==1

* elimination of the microstates
egen mpop=mean(pop), by(reporter)
drop if mpop<1000000

* ratios

egen WorldExport = sum(TotalExport),by (year) 
gen shareworld = TotalExport/WorldExport
egen Worldnber = sum(Nber),by (year) 
gen shareworldnber = Nber/Worldnber

keep reporter year shareworld shareworldnber 
sort reporter year
merge reporter year using SectionRatio.dta 

drop _merge

gen weighted_shareworld = Vold * shareworld
gen weighted_nber = Nold * shareworldnber

egen  Total_section_share = sum(weighted_shareworld), by (section year)
egen  Total_nber_section_share = sum(weighted_nber), by (section year)

collapse  Total_section_share Total_nber_section_share, by(section)
twoway (scatter Total_section_share Total_nber_section_share, sort mlabel(section)) (line Total_nber_section_share Total_nber_section_share, sort lcolor(red) lpattern(solid) lwidth(medthick)), ytitle(Share of export value in total export) xtitle(Share of export number of lines in total export) legend(off)
